#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File        :   383. 赎金信.py    
@Contact     :   lhouctcs@163.com
@License     :   MIT
@Time        :   2023/2/7 21:51
@Author      :   lhou 
@Version     :   0.1.0
@Description :
"""


# import lib
class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
        shortDic = dict()
        longDic = dict()
        for i in ransomNote:
            if i in shortDic:
                shortDic[i] += 1
                continue
            shortDic[i] = 1
        for i in magazine:
            if i in longDic:
                longDic[i] += 1
                continue
            longDic[i] = 1
        for k, v in shortDic.items():
            if k not in longDic or v > longDic[k]:
                return False
        return True
